/**
 * 功能描述
 */

define(function (require, exports, module) {
	var Subnav = require("subnav");
	
    var instance = {
        initComponent: function (params,widget) {
        	var subnav = new Subnav({
        		parentNode: ".J-subnav",
        		model: {
        			title: "机构预收/预付款",
        			items:[
//        			       {
//        				id:"servicepoint",
//            			type:"buttongroup",
//            			url:"api/servicepoint/operableservicepoints",
//            			tip:"服务点",
//						keyField :"pkServicePoint",
//						valueField :"name",
//            			params:{
//							fetchProperties:"pkServicePoint,name"
//						},
//						handler: function(key,element){
//							widget.get("grid").refresh();
//						}
//        			},
        			{
        				id : "startDate",
						type : "daterange",
						ranges : {
					        "本年": [moment().startOf("year"), moment().endOf("days")],
					        "本月": [moment().startOf("month"), moment().endOf("month")]
						},
						tip : "开始日期",
						defaultRange : "本月",
						handler : function(time){
							 widget.get("grid").refresh();
						}
        			},{
        				id:"add",
        				type:"button",
        				text:"新增",
        				handler:function(){
        					widget.get("form").reset();
        					widget.show([".J-form"]).hide([".J-grid"]);
							widget.get("subnav").hide(["add","startDate"]).show(["return"]);
        				}
        			},{
        				id: "return",
						type: "button",
						text: "返回",						
						show: false,
						handler:function(){
							widget.show([".J-grid"]).hide([".J-form"]);
							widget.get("subnav").hide(["return"]).show(["add","startDate"]);
						}
        			}]
        		}
        	});
        	widget.set("subnav", subnav);
        }
    };
    module.exports = instance;
});
